package com.shwread.android.ui.dialog;

import android.app.ActionBar.LayoutParams;
import android.app.Dialog;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.shwread.android.qysw.activity.LoginActivity;
import com.shwread.android.qysw10000204.R;

import logic.constants.DefaultConsts;

/**
 * 服务到期提醒
 * @author zhangnannan
 *
 */
public class ServiceTimeOutDialog
        extends
        Dialog
        implements
        android.view.View.OnClickListener
{
	private LoginActivity  activity;
	private Button   btnActivate,btnCancel;
	private TextView tvContent;
	
	public ServiceTimeOutDialog(LoginActivity activity) {
		super(activity, R.style.common_dialog);
		getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
		getWindow().setGravity(Gravity.CENTER_VERTICAL);
		
		this.activity = activity;
		findViews();
		setOnClick();
	}
	
	private void setOnClick() {
		btnCancel.setOnClickListener(this);
		btnActivate.setOnClickListener(this);
	}
	
	private void findViews() {
		View view = LayoutInflater.from(activity).inflate(R.layout.service_time_out_dialog, null);
		
		btnActivate = (Button) view.findViewById(R.id.service_time_out_dialog_activate_btn);
		btnCancel = (Button) view.findViewById(R.id.service_time_out_dialog_cancel_btn);
		tvContent = (TextView) view.findViewById(R.id.service_time_out_dialog_tv);
		setContentView(view);
	}
	
	protected void clickCancel(View v) {
//		activity.getUIHandler().sendEmptyMessage(1000);
		dismiss();
	}
	
	private void cliclckActivate(View v) {
	    activity.getUIHandler().sendEmptyMessage(DefaultConsts.GO_BOOKTICKET);
	    dismiss();
    }
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.service_time_out_dialog_cancel_btn:
				clickCancel(v);
				break;
			case R.id.service_time_out_dialog_activate_btn:
				cliclckActivate(v);
				break;
			default:
				break;
		}
	}


}
